package za.org.jcicada.cfgmngr.impl;

import za.org.jcicada.cfgmngr.IConfigurationServer;
import za.org.jcicada.cfgmngr.impl.katcp.ConfigurationKatcpSerializer;
import za.org.jcicada.comms.IConnection;
import za.org.jcicada.comms.IKatcpSerializerStrategy;
import za.org.jcicada.comms.IMessageListener;
import za.org.jcicada.comms.impl.AcceptListenerBase;

/**
 * Katcomms accept listener that accepts connections and ties them to a given
 * IConfigurationServer.
 */
public class ConfigurationAcceptListener extends AcceptListenerBase {

    /**
     * IConfigurationServer implementation to delegate requests to.
     */
    protected IConfigurationServer configurationServer;

    /**
     * Create an accept listener that listens for clients and passes messages
     * through to the given IAlarmSubject implementation.
     */
    public ConfigurationAcceptListener(IConfigurationServer configurationServer) {
        this.configurationServer = configurationServer;
    }

    /**
     * Create message listeners for new connections. Implements abstract method
     * from AcceptListenerBase.
     * 
     * @param connection New connection from client.
     */
    public IMessageListener createListener(IConnection connection) {
        return new ConfigurationMessaging(connection, configurationServer);
    }

	@Override
	public IKatcpSerializerStrategy getKatcpSerializerStrategy() {
		return new ConfigurationKatcpSerializer();
	}

}
